﻿<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<%
response.setHeader("Cache-Control","no-store");
response.setHeader("Pragrma","no-cache");
response.setDateHeader("Expires",0);
%>
<!DOCTYPE html>
<html>
<head>
<base href="<%=basePath%>"/>
<link rel="shortcut icon" href="images/store.png" /><!--图片log  -->
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no">
<link href="css/base.css" rel="stylesheet">
<link href="css/order.css?v=0730" rel="stylesheet"/>
<link href="css/shopcar.css?v=0704" rel="stylesheet"/>
<title>订单确认</title>
</head>
<body>
    <div class="by_w" id="by_w" style="padding: 0px 0px 55px;">
        <div>
            <div class="m_pagetop" align="center">
                <span class="m_goback" onclick="document.location.href = 'javascript:history.go(-1)';"></span>
                <span class="m_title">订单确认</span>
            </div>
        </div>
        <section class="order-item-group order-address">
            <a id="address-list" class="order-item address-arrow" style="height:auto;min-height:30px">
                <div style="margin-left:10px;text-align:left">
                    <span class="name"></span>
                    <span class="telephone"></span>
                </div>
                <div class="address"></div>
            </a>
            <input name="address_id" class="address_id" type="hidden">
        </section>
        <div id="shopcar" class="shopcar">
            <div class="m_carsj">
                <div class="m_sj_tt" align="left">
                    <span class="m_sj_namet" id="supplier">湖南恒昌医药有限公司</span>
                </div>
                <div id="productlist">
                	<c:forEach items="${cartList}" var="cart">
                        <table class="m_c_tab">
                            <tbody>
                                <tr>
                                    <td width="20%" valign="middle" style="padding:0px 10px">
                                    <input type="hidden" class="hidden" value="${cart.cid}"/>
                                    <input type="hidden" class="jlgg" value="${cart.jlgg}"/>
                                    <input type="hidden" class="flbid" value="${cart.flbid}"/>
                                        <a class="m_p_plink touri">
                                            <img src="http://www.hnhcyy.com/resource/img/${cart.spid}/10.jpg" width="60px" height="60px">
                                        </a>
                                    </td>
                                    <td width="60%" valign="middle" align="left" style="position:relative">
                                    <c:set value="${cart.zengsong}" var="zengsong"></c:set>
                                    <!-- 起送数量 -->
                                    <c:set value="${zengsong.fqty}" var="fqty"></c:set>
                                    <c:if test="${zengsong!=null && cart.FQty>=fqty}">
											<span class="gift">礼</span>
									</c:if>
                                        <span class="m_p_name escp">${cart.spmch}</span>
                                        <span class="o_p_cm2 escp">批号：≥${cart.pihao}</span>
                                    <c:if test="${zengsong!=null && cart.FQty>=fqty}">
                                    	<!--单位赠送数量  -->
                                    	<c:set value="${zengsong.zs_qty}" var="zs_qty"></c:set>
                                    	<!-- 计算赠送总数量 -->
                                    	<c:set value="${(cart.FQty/fqty)*zs_qty}" var="total_qty"></c:set>
                                    	<c:if test="${zengsong.fkind==1}">
	                                     	<span class="size">选择尺码</span>
	                                     	<input class="total_qty" value="${total_qty}" hidden>
                                     	</c:if>
                                     	<c:if test="${zengsong.fkind==2}">
                                     		<span style="color: #da0203;">送：</span>
                                     		<span class="zs_info">${zengsong.zs_spmch}<fmt:formatNumber type="number" value="${total_qty}" maxFractionDigits="0"/>${zengsong.zs_dw}</span>
                                     	</c:if>
                                    </c:if>
                                    </td>
                                    <td width="20%" valign="middle" align="right" style="padding-right: 10px;">
                                        <span class="o_jg">￥${cart.FPrice}</span>
                                        <span class="o_p_num">x ${cart.FQty}</span>
                                        <input type="hidden" class="num" value="${cart.FQty}"/>
                                    </td>
                                </tr>
                            </tbody>
                        </table>
                    </c:forEach>
                </div>
                <div id="beizhu1" hidden>
	                <span>赠送：</span>
	                <span id="msg"></span>
                </div>
                <div class="m_omessage">
                    <textarea class="m_message" id="m_message" name="m_message" maxlength="250" placeholder="输入留言内容"></textarea>
                </div>
                <div class="m_oxj" align="right">
                    <span class="f14">共&nbsp;${cartList.size()}&nbsp;件</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                    <span class="f14">合计：</span>
                    <span id="sj_price" class="m_ajg"></span>
                </div>
            </div>
            <div class="m_jffp">
                <div class="m_fp" align="left">
                    <span class="o_title">发票信息</span>
                </div>
                <div class="m_ofp" align="left">
                    <table>
                        <tbody>
                            <tr style="height:30px;">
                                <td class="f12" width="80px">发票类型：</td>
                                <td class="f12">纸质发票</td>
                            </tr>
                            <tr style="height:30px;">
                                <td class="f12">发票内容：</td>
                                <td class="f12">明细</td>
                            </tr>
                            <tr style="height:30px;">
                                <td class="f12">发票抬头：</td>
                                <td>
                                    <span class="fp_all">
                                        <span fp_type="1" class="fp_a fp_fp fp_ck"></span>
                                        <span class="fp_b f12">普通发票</span>
                                    </span>
                                    <!-- <span class="fp_all">
                                        <span fp_type="2" class="fp_c fp_fp"></span>
                                        <span class="fp_d f12">专用发票</span>
                                    </span> -->
                                </td>
                            </tr>
                            <tr>
                            	<td class="f12">税&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;号：</td>
                            	<td>
                            		<span id="shwdjh"></span>
                            		<input id="in_shwdjh" placeholder="请填写税号">
                            	</td>
                            </tr>
                            <tr style="height:30px;">
                                <td class="f12">配送方式：</td>
                                <td>
                                    <span class="thfs">
                                        <span class="fp_a fp_fp fp_ck"></span>
                                        <span class="fp_b f12">EMS</span>
                                    </span>
                                    <span class="thfs">
                                        <span class="fp_c fp_fp"></span>
                                        <span class="fp_d f12">韵达</span>
                                    </span>
                                </td>
                            </tr>
                        </tbody>
                    </table>
                </div>
            </div>
            <div class="m_carsub bbox" align="right">
                <span class="m_zjg f_l">
                    <span id="totalstr">实付款：</span>
                    <span class="m_a_prie" id="totalamount"></span>
                </span>
                <input type="button" class="m_sub_btn" value="提交订单">
            </div>
        </div>
    </div>
	<jsp:include page="part/size.jsp"></jsp:include>
    <div id="loading" style="position:fixed;z-index:99;right:24%;bottom:1%;display:none">
    	<img src="images/waiting.jpg" style="width:70%">
    </div>
<script>
var sjid=${sjid};
</script>     
<script src="//cdn.bootcss.com/jquery/1.11.0/jquery.min.js"></script>
<script src="js/order_confirm.js?v=070801"></script>
<script src="js/gift.js?v=0719"></script>
<script>
 //下达订单
 $(".m_sub_btn").click(function () {
	if(!checkOrder())return;//检查订单金额是否符合要求、赠品是否选择尺码
    var totalamount = totalprice;//总金额
	var invoicetype = $(".fp_all .fp_ck").attr("fp_type");//发票类型
    var fnote = $("#m_message").val();//留言
    var beizhu1 = $("#beizhu1 #msg").html();//赠品信息
    var thfs = $(".thfs .fp_ck").next().html();//提货方式
    var shwdjh = $("#in_shwdjh").val(); //税号
    var cids = new Array();
    $(".hidden").each(function () {
         var id = $(this).val();
         cids.push(id);
    });
    var idarray = cids.join(",");
    $("#loading").show();
    $.ajax({
     	 url:'Shop/GoOrder/Index?token=${token}&sjid='+sjid,
     	 data: JSON.stringify({
             totalamount: totalamount, paytype: 5,idarray: idarray,fnote: fnote, 
             beizhu1:beizhu1,invoicetype:invoicetype, thfs: thfs, shwdjh:shwdjh}),
         type:'post',
         contentType:"application/json;charset=utf-8",
         success:function(data){
         	if (data.sid) {
         		$("#loading").hide();
         		alert("提交订单成功！");
               	location.href ="Shop/User?sjid="+sjid;
            }
            else {
            	alert("提交订单失败！");
            	$("#loading").hide();
            }
         }
     })
 });
</script>
</body>
</html>